<template>
    <div>
        <van-field
            v-model="date"
            :placeholder="placeholder"
            readonly="readonly"
            :name="name"
            :label="label"
            @click="endTimePop = true"
            :rules="[{ required: true, message: msg }]"
        />
        <van-popup v-model="endTimePop" label="离开时间" position="bottom" :overlay="true">
            <van-datetime-picker
                v-model="currentDate"
                type="date"
                @cancel="endTimePop = false"
                @confirm="endTimeChange"
            />
        </van-popup>
    </div>
</template>

<script>
import {dateFormate} from "@/uitl/util";

export default {
    name: "vanDateDopup",
    props: ["name", "label", "placeholder", "msg"],
    data() {
        return {
            currentDate: new Date(),
            endTimePop: false,
            date: "",
        }
    },
    methods: {
        endTimeChange(e) {
            this.date = dateFormate("Y-m-d", e)
            this.endTimePop = false
        },
    },
}
</script>

<style scoped>

</style>